//
//  AppDelegate+Net.m
//  DoulinClient
//
//  Created by ypj on 2021/11/27.
//

#import "AppDelegate+Net.h"
#define BaseUrl @""
@implementation AppDelegate (Net)

+ (void)netCfg{
    YTKNetworkAgent *agent = [YTKNetworkAgent sharedAgent];
    NSSet *set = [NSSet setWithObjects:@"application/json",@"text/plain",@"text/javascript",@"text/json",@"text/html",@"text/css",nil];
    [agent setValue:set forKeyPath:@"_manager.responseSerializer.acceptableContentTypes"];
    YTKNetworkConfig *config = [YTKNetworkConfig sharedConfig];
    config.baseUrl = DOMAIN_URL;
}

+ (void)monitorNetworking{
     AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
    [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status){
        switch(status){
            case AFNetworkReachabilityStatusUnknown:{
                NSLog(@"<-- %s, %d --> 🐔未知网络", __FUNCTION__, __LINE__);
            }
            break;
            case AFNetworkReachabilityStatusNotReachable:{
                NSLog(@"<-- %s, %d --> 🐔网络不可达", __FUNCTION__, __LINE__);
            }
            break;
            case AFNetworkReachabilityStatusReachableViaWWAN:{
                 NSLog(@"<-- %s, %d --> 🐔GPRS网络", __FUNCTION__, __LINE__);
            }
            break;
            case AFNetworkReachabilityStatusReachableViaWiFi:{
                NSLog(@"<-- %s, %d --> 🐔wifi网络", __FUNCTION__, __LINE__);
            }
            break;
            default:
            break;
        }
        if (status == AFNetworkReachabilityStatusReachableViaWWAN || status == AFNetworkReachabilityStatusReachableViaWiFi){
             NSLog(@"<-- %s, %d --> 🐔有网了", __FUNCTION__, __LINE__);
//            [kNotifyCenter postNotificationName:YLNetworkNotify object:@(YES)];
        } else {
             NSLog(@"<-- %s, %d --> 🐔没网了", __FUNCTION__, __LINE__);
//            [kNotifyCenter postNotificationName:YLNetworkNotify object:@(NO)];
            [MSNetworkManager showNoNetAlert];
        }
    }];
        [manager startMonitoring];
}
@end
